package com.niit.feign.clients;

import com.niit.feign.config.UserClientConfig;
import com.niit.feign.fallback.UserClientFallback;
import com.niit.feign.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author yaojianfeng
 */
@FeignClient(value = "userservice",configuration = UserClientConfig.class,fallback = UserClientFallback.class)
public interface UserClient {
    /**
     * 根据ID获取用户信息
     * @param id
     * @return
     */
    @GetMapping("/user/{id}")
    User findUserById(@PathVariable("id") String id);


    /**
     * request参数的请求
     * @param name
     * @return
     */
    @GetMapping(value = "/provider/feign/request")
    public String requestParam (@RequestParam String name);

    /**
     * header信息的请求
     * @param name
     * @param address
     * @return
     */
    @GetMapping(value = "/provider/feign/header" )
    public User headerInfo(@RequestHeader String name, @RequestHeader String address);

    /**
     * requestbody的请求
     * @param user
     * @return
     */
    @PostMapping(value = "/provider/feign/body")
    public String bodyInfo(@RequestBody User user) ;
}
